open WRBUFF1,">out_only_sig_eqtl";
open WRBUFF2,">out_sig_eqtl_gene_expr";
open WRBUFF3,">out_sig_eqtl_genotyping";
open WRBUFF4,">out_only_sig_gene_expr";
open WRBUFF5,">out_only_sig_genotyping";
open BUFF,"gbm_expression_survival.txt" or die "no file exists gene expr survival\n";
$line = <BUFF>;
while(<BUFF>)
{
        chomp($_);
        @arr = split(/\t/,$_);
	if($arr[2] <= 0.05)
        {
		$genesurival{$arr[1]} = $arr[2];
	}
}
close(BUFF);
open BUFF,"gbm_genotyping_survival.txt" or die "no file exists genotyping survival\n";
$line = <BUFF>;
while(<BUFF>)
{
        chomp($_);
        @arr = split(/\t/,$_);
        if($arr[1] <= 0.05)
        {
                $genotypingsurival{$arr[0]} = $arr[1];
        }
}
close(BUFF);
open BUFF,"gbm_outfile_result" or die "no file exists\n";
$line = <BUFF>;
while(<BUFF>)
{
        chomp($_);
        @arr = split(/\t/,$_);
        if($arr[9] <= 0.05)
        {
                print WRBUFF1 "$arr[0]\t$arr[1]\t$arr[9]\n";
		if(exists($genotypingsurival{$arr[1]}))
		{
			 print WRBUFF3 "$arr[0]\t$arr[1]\t$arr[9]\t$genotypingsurival{$arr[1]}\n";
		}
		if(exists($genesurival{$arr[0]}))
		{
			print WRBUFF2 "$arr[0]\t$arr[1]\t$arr[9]\t$genesurival{$arr[0]}\n";
		}
        }
	if(exists($genotypingsurival{$arr[1]}))
        {
        	print WRBUFF5 "$arr[0]\t$arr[1]\t$arr[9]\t$genotypingsurival{$arr[1]}\n";
        }
        if(exists($genesurival{$arr[0]}))
       	{
                print WRBUFF4 "$arr[0]\t$arr[1]\t$arr[9]\t$genesurival{$arr[0]}\n";
        }

}
close(WRBUFF1);
close(WRBUFF2);
close(WRBUFF3);
close(WRBUFF4);
close(WRBUFF5);
